package com.tico.editor.editors.service.impl;

import com.tico.common.service.impl.AbstractService;
import com.tico.common.utils.BaseQuery;
import com.tico.common.utils.QueryResult;
import com.tico.editor.editors.domain.KafkaTopic;
import com.tico.editor.editors.mapper.KafkaTopicMapper;
import com.tico.editor.editors.service.KafkaTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 */
@Service
public class KafkaTopicServiceImpl extends AbstractService<KafkaTopic> implements KafkaTopicService {


   @Autowired
   KafkaTopicMapper kafkaTopicMapper;

   @Override
   public KafkaTopic findById(Serializable id) {
     return kafkaTopicMapper.findById(id);
   }

    @Override
    public int insertBatch(List<KafkaTopic> kafkaTopics) {
      return kafkaTopicMapper.insertBatch(kafkaTopics);
    }

    @Override
    public int insert(KafkaTopic kafkaTopic) {
      return kafkaTopicMapper.insert(kafkaTopic);
    }
    @Override
    public List<KafkaTopic > findByNamedParamList(Map<String,Object> param){
        return kafkaTopicMapper.findByNamedParamList(param);
    }

    @Override
    public List<String> findTopicByParamList(Map<String, Object> param) {
        return kafkaTopicMapper.findTopicByParamList(param);
    }

    @Override
    public int delete(Serializable id) {
      return kafkaTopicMapper.delete(id);
    }
    @Override
    public int update(KafkaTopic topic) {
      return kafkaTopicMapper.update(topic);
    }

    @Override
    public int remove(Serializable id) {
      return kafkaTopicMapper.remove(id);
    }

    @Override
    public QueryResult<KafkaTopic> findPageInfo(BaseQuery baseQuery) {
        QueryResult<KafkaTopic> result = new QueryResult<KafkaTopic>();
        result.setQuery(baseQuery);
        Map
        <String, Object> params = result.getQuery().build();
        Integer amount = this.kafkaTopicMapper.countPageInfo(params);
        result.setTotalRecord(amount);
        if (amount == 0) {
        return result;
        }
        List<KafkaTopic> list = kafkaTopicMapper.findPageInfo(params);
        if (!CollectionUtils.isEmpty(list)) {
        result.setResultList(list);

        }
        return result;
    }
}
